﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>权限管理</title>
    <#include "../common/link.ftl" >
    <script>
        $(function () {
            $('.btn-delete').click(function () {
                var id = $(this).data("id");
                $.messager.confirm("警告","是否确认删除！",function(){
                    $.get('/permission/delete.do',{id,id},handlerMessageP)

                })
            })

            $(".btn-input").click(function(){
                $('.btn-input').val('');

                var json = $(this).data("json");
                $('#myModal').modal("show");
                if(json){
                    $('#editForm input[name=id]').val(json.id);
                    $('#editForm input[name=name]').val(json.name);
                    $('#editForm input[name=expression]').val(json.expression);
                }
            });
            $('.btn-submitsave').click(function () {

                $('#editForm').ajaxSubmit(handlerMessageP)

            })
            $(".btn_reload").click(function () {
                $.get('/permission/load.do',function (data) {
                    if(data.success){
                        window.location.reload(); //重新加载当前页面
                    }else{
                        alert(data.msg)
                    }
                })
            })
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl" >
    <!--菜单回显-->
    <#assign currentMenu="permission"/>
    <#include "../common/menu.ftl" >
    <div class="content-wrapper">
        <section class="content-header">
            <h1>权限管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/permission/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="javascript:;" class="btn btn-success btn_reload" style="margin: 10px;">
                        <span class="glyphicon glyphicon-repeat"></span>  重新加载
                    </a>
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>权限名称</th>
                            <th>权限编号</th>
                            <th>操作</th>
                        </tr>
                        <#list result.list as entity>
                            <tr>
                                <td>${entity_index+1}</td>
                                <td>${entity.name!}</td>
                                <td>${entity.expression!}</td>
                                <td>
                                    <a href="#"
                                       class="btn btn-info btn-xs btn-input" data-json='${entity.json}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                    <a href="#"
                                       class="btn btn-danger btn-xs btn-delete" data-id='${entity.id}'>
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                    <div style="text-align: center;">
                     <ul id="pagination-demo" class="pagination-sm"></ul>
                    </div>

                </div>
            </div>
        </section>
    </div>

    <#include "../common/footer.ftl" >
</div>
<#--模态框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">新增 / 编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/permission/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="${(entity.id)!}" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">权限名称：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="name" name="name" value="${(entity.name)!}"
                                   placeholder="请输入权限名">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="expression" class="col-sm-3 control-label">编码：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="expression" name="expression" value="${(entity.expression)!}"
                                   placeholder="请输入权限编码">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submitsave">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
